/*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 ("License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is: CalemEAM MicroLocale Test Suite.
*
* The Initial Developer of the Original Code is CalemEAM Inc.
* Portions created by CalemEAM are Copyright (C) 2008 CalemEAM Inc.
* All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK *****
*/

package test;

import com.calemeam.text.MicroResIf;
import java.util.Hashtable;

/**
 * MicroRes test mockup class.
 * @author cli
 */
public class MicroResImpl implements MicroResIf {
   /**
    * Make it a singleton
    */
   public static MicroResIf i=new MicroResImpl();
   
   /**
    * May use a property file for this purpose.
    */
   public static final String[] RES_AR_MM={
      "Jan", "Feb", "Mar", "Apr",
      "May", "Jun", "Jul", "Aug",
      "Sep", "Oct", "Nov", "Dec"
   };
   public static final String[] RES_DOW_M={
      "Sun", "Mon", "Tue", "Wed", 
      "Thu", "Fri", "Sat"
   };
   /**
    * am and pm key
    */
   public static final String res_am="AM";
   public static final String res_pm="PM";
   
   /**
    * res map
    */
   public static Hashtable resMap;
   
   /**
    * Static initializer.
    */
   static {
      resMap=new Hashtable();
      initRes(MicroResIf.AR_MM, RES_AR_MM, resMap);
      initRes(MicroResIf.DOW_M, RES_DOW_M, resMap);
      resMap.put(MicroResIf.am_key, res_am);
      resMap.put(MicroResIf.pm_key, res_pm);
      //Numbers
      resMap.put(MicroResIf.decimal_key, ".");
      resMap.put(MicroResIf.grouping_key, ",");
      resMap.put(MicroResIf.minus_key, "-");
      resMap.put(MicroResIf.percent_key, "%");
      resMap.put(MicroResIf.zero_key, "0");
   }
   
   public static void initRes(String[] keys, String[] vals, Hashtable res) {
      for (int i=0; i< keys.length; i++) {
         res.put(keys[i], vals[i]);
      }
   }
   
   /**
    * Interface method
    */
   public String get(Object key) {
      return (String)resMap.get(key);
   }
}
